#ifndef _INC_CALENDAR_T_H_
#define _INC_CALENDAR_T_H_

#include <map>

class Appointment_t;
class DayTime_t;

class Calendar_t
{
public:
	/**
	* Ctor
	*/
	Calendar_t();

	/**
	* Dtor
	*/
	virtual ~Calendar_t();

	/**
	* Copy Ctor
	*/
	Calendar_t(const Calendar_t& other);

	/**
	* Operator=
	*/
	Calendar_t& operator=(const Calendar_t& other);

	/**
	* Attempts to insert given appointment to this calender
	* Returns true if successful, false otherwise
	*/
	virtual bool insert(Appointment_t* const appointment);

	/**
	* Attempts to remove given appointment from this calender
	* Deletes ptr if requested
	* Returns true if successful, false otherwise
	*/
	virtual bool remove(const Appointment_t& appointment, bool deletePtr = false);

	/**
	* Removes all appointments from this calender
	* Deletes ptrs if requested
	*/
	virtual void removeAll(bool deletePtrs = false);

	/**
	* Attempts to find given appointment in this calender
	* Returns invalid appointment if not found
	*/
	virtual const Appointment_t& find(const DayTime_t& startTime) const;

	/**
	* Atempts to duplicate given appointment to other day and time
	* Returns true if successful, false otherwise
	*/
	virtual bool duplicate(const Appointment_t& appointment, 
				   const DayTime_t& startTime);

private:
	/**
	* Attempts to lookup given appointment in this calender
	* Returns NULL if not found
	*/
	Appointment_t* lookup(const DayTime_t& startTime) const;

	/**
	* Returns true whether given appointment intersects with another appointment in this calendar
	*/
	bool intersects(const Appointment_t& appointment) const;

	typedef std::map<DayTime_t, Appointment_t*> AppointmentsContainer; // Appointments container typedef
	AppointmentsContainer m_appointments; // Appointments container

	/**
	* Operator<<
	*/
	friend std::ostream& operator<<(std::ostream& os, const Calendar_t& cal);
};

#endif // _INC_CALENDAR_T_H_